const Koa = require('koa');
const router = require('koa-router')();
const views = require('koa-views');

class Server {
    #port = 3080
    index = async ctx => {
        // await ctx.render('index.html') // 有些单词很简单，很常用，但我们并不会使用，比如 render、profile
        await ctx.render('index') // 默认的扩展名就是 “.html”
    }

    constructor() {
        router.get('/', this.index)

        new Koa()
            .use(views(__dirname))
            .use(router.routes())
            .listen(
                this.#port,
                _ => console.log(`Server running on http://localhost:${this.#port}`));
    }
}

new Server();
